package com.jinmdz.fmis.dao.dao;

import com.jinmdz.fmis.dao.dao.provider.CremationFurnaceProvider;
import com.jinmdz.fmis.dao.model.cremation.CremationFurnaceItem;
import com.jinmdz.fmis.dao.model.cremation.CremationFurnaceViewItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

import java.util.ArrayList;

/**
 * 火化炉Dao
 *
 * @author LiCongLu
 * @date 2020-02-15 10:08
 */
public interface CremationFurnaceDao {

    /**
     * 按照主键获取火化炉信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-02-15 19:37
     */
    @Select(" select id,furnace_type_code,furnace_code,furnace_describe,furnace_state,disable_state,sort,remark,version " +
            " from cremation_furnace where id = #{id} and deleted=0 ")
    CremationFurnaceItem getCremationFurnaceById(@Param("id") Integer id);

    /**
     * 按照类型字典编码值查询火化炉
     *
     * @param dictCode 火化类型字典编码
     * @param dataCode 火化类型编码
     * @return
     * @author LiCongLu
     * @date 2020-02-15 19:37
     */
    @SelectProvider(type = CremationFurnaceProvider.class, method = "listCremationFurnaceByDictCode")
    ArrayList<CremationFurnaceItem> listCremationFurnaceByDictCode(@Param("dictCode") String dictCode, @Param("dataCode") Integer dataCode);


    /**
     * 按照主键获取火化炉信息
     *
     * @param id 主键
     * @return
     * @author LiCongLu
     * @date 2020-02-17 19:34
     */
    @SelectProvider(type = CremationFurnaceProvider.class, method = "getCremationFurnaceViewById")
    CremationFurnaceViewItem getCremationFurnaceViewById(@Param("id") Integer id);

    /**
     * 按照类型字典编码值查询火化炉信息
     *
     * @param dictCode 类型字典编码
     * @param dataCode 类型编码
     * @return
     * @author LiCongLu
     * @date 2020-02-17 19:34
     */
    @SelectProvider(type = CremationFurnaceProvider.class, method = "listCremationFurnaceViewByDictCode")
    ArrayList<CremationFurnaceViewItem> listCremationFurnaceViewByDictCode(@Param("dictCode") String dictCode, @Param("dataCode") Integer dataCode);

    /**
     * 更新状态值
     *
     * @param state          状态值
     * @param modifiedUserId 修改帐号
     * @param id             主键
     * @param version        版本号
     * @return
     * @author LiCongLu
     * @date 2020-02-17 19:34
     */
    @Update(" update cremation_furnace set furnace_state = #{state},modified_user_id = #{modifiedUserId},version = unix_timestamp(now()) where id = #{id} and version = #{version} and unmodified = 0 and deleted = 0 ")
    void updateStateById(@Param("state") Integer state, @Param("id") Integer id, @Param("modifiedUserId") Integer modifiedUserId, @Param("version") Long version);
}
